package com.spring.spittr.config;

import org.springframework.web.WebApplicationInitializer;

import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

/**
 * @author tonywang
 * @date 6/21/2018
 */
public class MyServletInitializer implements WebApplicationInitializer {
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        ServletRegistration.Dynamic myServlet  = servletContext.addServlet("myServlet",MyServlet.class);
        myServlet.addMapping("/custom/**");
        FilterRegistration.Dynamic myFilter = servletContext.addFilter("myFilter",MyFilter.class);
        myFilter.addMappingForUrlPatterns(null,false,"/custom/filter/**");
    }
}
